import "babel-polyfill";
import Vue from "vue";
import App from "./App";
import store from "./store/";
import routerMap from "./router";
import VueRouter from "vue-router";
import VueResource from "vue-resource";
import MintUI from "mint-ui";
import "mint-ui/lib/style.css";
import VueLazyload from "vue-lazyload";

import base from "./utils/base";
Vue.use(base);
import "./styles/base.css";
import "./styles/commonly.css";
import "./styles/mintBase.css";
import "./styles/util.css";
Vue.use(VueLazyload);
Vue.use(VueRouter);
Vue.use(VueResource);
Vue.use(MintUI);

Vue.http.options.emulateJSON = true;
// 并且配置路由规则  history hash
var router = new VueRouter({
  mode: "hash",
  base: __dirname,
  routes: routerMap
});
var app = new Vue({
  store,
  router,
  render: h => h(App)
}).$mount("#app");

// 全局过滤
import filter from "./utils/filter";
for (let key in filter) {
  Vue.filter(key, filter[key]);
}

// 页面置于顶部
router.afterEach((to, from, next) => {
  window.scrollTo(0, 0);
  document.documentElement.scrollTop = 0;
});
